package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.CheckInMeeting;
import com.eling.elcms.travel.service.ICheckInMeetingManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
@Controller
public class CheckInMeetingController extends BaseFormController{

	@Autowired
	private ICheckInMeetingManager service;
	
	@RequestMapping("/api/checkinmeeting/save")
    @ResponseBody
	public CheckInMeeting save(@ModelAttribute@ModelFilling CheckInMeeting dinner){
		return service.save(dinner);
	}
	
	@RequestMapping("/api/checkinmeeting/{pkCheckInMeeting}/delete")
	@ResponseBody
	public Msg delete(@PathVariable Long pkCheckInMeeting){
		service.remove(pkCheckInMeeting);
		return new Msg("删除成功");
	}
	
	@RequestMapping("/api/checkinmeeting/query")
    @ResponseBody
	public List<CheckInMeeting> query(@ModelAttribute CheckInMeeting dinner){
		return service.query(dinner);
	}
	
	@RequestMapping("/api/checkinmeeting/search*")
	@ResponseBody
	public List<CheckInMeeting> search(@ModelAttribute SearchCondition sc,@ModelAttribute CheckInMeeting dinner){
		sc.setQueryCondition(dinner);
		return service.search(sc);
	}	
	
	@RequestMapping("/api/checkinmeeting/confirm")
    @ResponseBody
	public CheckInMeeting confirm(@ModelAttribute@ModelFilling CheckInMeeting dinner){
		return service.confirm(dinner);
	}
	
	/**
	 * 查询会议落实
	 * @param checkInMeeting
	 * @param startDate
	 * @param endDate
	 * @return
	 * @author zhoulin
	 */
	@RequestMapping("/api/checkinmeeting/queryall")
	@ResponseBody
	public List<CheckInMeeting> queryAll(@ModelAttribute CheckInMeeting checkInMeeting,
			@RequestParam(name = "startDate", required = false) Date startDate,
			@RequestParam(name = "endDate", required = false) Date endDate) {
		return service.queryAll(checkInMeeting, startDate, endDate);
	}

}

